# 方法一，暴力遍历
def return_index1(int_arr,num):
    for i in range(len(int_arr)):
        if int_arr[i]==num:
            return i
    return None

# 改进方法2：考虑到是有序的，所以我们假设他是递增的，
# 那么如果有个数组元素大于num，就直接返回false就好了，不用继续了
def return_index2(int_arr,num):
    for i in range(len(int_arr)):
        if int_arr[i]==num:
            return i
        elif int_arr[i]>num:
            return None
    return None

# 改进方法3：二分查找法
def return_index3(int_arr,num):
    left = 0
    right = len(int_arr)-1
    while left<=right:
        mid = (right+left)//2
        if int_arr[mid]>num:
            right = mid-1
        elif int_arr[mid]==num:
            return mid
        else:
            left = mid+1
    return None

for i in range(1,11):
    print(return_index3([1,2,3,4,6,7,8,9],i))